package com.qwz.example;

import com.qwz.common.DbClose;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;

public class UserManager {
    public Collection<UserModelApi> getUserBudepId(String depId) {

        Collection<UserModelApi> collection = new ArrayList<UserModelApi>();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection("");
            String sql = "select userid,name from t_user where depid=?";
            ps = conn.prepareStatement(sql);
            ps.setString(1, depId);
            rs = ps.executeQuery();
            while (rs.next()) {
                Proxy proxy = new Proxy(new UserModel());
                proxy.setUserId(rs.getString("userid"));
                proxy.setName(rs.getString("name"));
                collection.add(proxy);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DbClose.close(conn, ps, rs);
        }
        return collection;
    }
}
